import { getToken, removeToken } from '@/utils/auth'

const state = {
  isLogin: false,
  token: '',
  name: '',
  image: '',
}

const mutations = {
  setIsLogin: (state, isLogin) => {
    state.isLogin = isLogin
  },
  setToken: (state, token) => {
    state.token = token
  },
  setName: (state, name) => {
    state.name = name
  },
  setImage: (state, image) => {
    state.image = image
  },
}

const actions = {
  setIsLogin ({commit}, isLogin) {
    commit('setIsLogin', isLogin)
  },
  setToken ({commit}, token) {
    commit('setToken', token)
  },
  setName ({commit}, name) {
    commit('setName', name)
  },
  setImage ({commit}, image) {
    commit('setImage', image)
  }
}
const getters = {
  token: state => {
    return state.token
  }
}

export default {
  state,
  mutations,
  actions,
  getters
}
